<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.6"/>
<title>BatteryCharger: pwm.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">BatteryCharger
   &#160;<span id="projectnumber">5.0</span>
   </div>
   <div id="projectbrief">A smart charger for lead-acid batteries.</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('pwm_8h.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#define-members">Macros</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">pwm.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p><a href="pwm_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
Macros</h2></td></tr>
<tr class="memitem:a76fe84d83b8d236bd4f0d20d7e2ed06f"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#a76fe84d83b8d236bd4f0d20d7e2ed06f">PWM_FREQ</a>&#160;&#160;&#160;25000</td></tr>
<tr class="separator:a76fe84d83b8d236bd4f0d20d7e2ed06f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a657672b9c81af0d339260870f5b6b4fc"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#a657672b9c81af0d339260870f5b6b4fc">PWM_DOWN_STEP</a>&#160;&#160;&#160;9</td></tr>
<tr class="separator:a657672b9c81af0d339260870f5b6b4fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ad558a75f53ae1894cc5bfbc1b6da792b"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#ad558a75f53ae1894cc5bfbc1b6da792b">PWM_UP_STEP</a>&#160;&#160;&#160;9</td></tr>
<tr class="separator:ad558a75f53ae1894cc5bfbc1b6da792b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aff28e7415e98ae7d3b2c88cabe778479"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#aff28e7415e98ae7d3b2c88cabe778479">MATCH_PIN</a>&#160;&#160;&#160;PIO1_9</td></tr>
<tr class="separator:aff28e7415e98ae7d3b2c88cabe778479"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aeb109f2e57328f6dd48e123888f364b4"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#aeb109f2e57328f6dd48e123888f364b4">MATCH_PIN_CONFIG</a>&#160;&#160;&#160;(1 &lt;&lt; 0)</td></tr>
<tr class="separator:aeb109f2e57328f6dd48e123888f364b4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8ac5fa9475b8b9d3561107fa48fac8b8"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#a8ac5fa9475b8b9d3561107fa48fac8b8">COUNTER_TIMER_CLK</a>&#160;&#160;&#160;(1 &lt;&lt; 8)</td></tr>
<tr class="separator:a8ac5fa9475b8b9d3561107fa48fac8b8"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa5696c49e88a24e3144fd1433c7d20e5"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#aa5696c49e88a24e3144fd1433c7d20e5">PWM_TIMER</a>&#160;&#160;&#160;LPC_TMR16B1</td></tr>
<tr class="separator:aa5696c49e88a24e3144fd1433c7d20e5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7905077bb6cb0ce86fad25d4db2e884d"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#a7905077bb6cb0ce86fad25d4db2e884d">PWM_GPIO</a>&#160;&#160;&#160;LPC_GPIO1</td></tr>
<tr class="separator:a7905077bb6cb0ce86fad25d4db2e884d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aee8f0eb1561b9783978d2094e7df220a"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#aee8f0eb1561b9783978d2094e7df220a">PWM_PIN_MSK</a>&#160;&#160;&#160;(1 &lt;&lt; 9)</td></tr>
<tr class="separator:aee8f0eb1561b9783978d2094e7df220a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afc17e670615df430220181dd6915ef01"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#afc17e670615df430220181dd6915ef01">ENABLE_TC</a>&#160;&#160;&#160;(1 &lt;&lt; 0)</td></tr>
<tr class="separator:afc17e670615df430220181dd6915ef01"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ac28f3dd83e2453ab0fd7f97d75299c49"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#ac28f3dd83e2453ab0fd7f97d75299c49">PWM_MATCH0</a>&#160;&#160;&#160;(1 &lt;&lt; 0)</td></tr>
<tr class="separator:ac28f3dd83e2453ab0fd7f97d75299c49"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2914d6ed83a15536c91ec89d7e6072ec"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#a2914d6ed83a15536c91ec89d7e6072ec">MATCH3_RESET</a>&#160;&#160;&#160;(1 &lt;&lt; 10)</td></tr>
<tr class="separator:a2914d6ed83a15536c91ec89d7e6072ec"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ad98784381838376693316887a2c3bf7a"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#ad98784381838376693316887a2c3bf7a">PWM_Start</a> ()</td></tr>
<tr class="separator:ad98784381838376693316887a2c3bf7a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a28a184018d9eeae0a6588e054ffe8e14"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#a28a184018d9eeae0a6588e054ffe8e14">PWM_Stop</a> ()</td></tr>
<tr class="separator:a28a184018d9eeae0a6588e054ffe8e14"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a70b61532b83a73726dc9d3a77ecffb9c"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#a70b61532b83a73726dc9d3a77ecffb9c">PWM_IncreaseDutyCycle</a> ()</td></tr>
<tr class="separator:a70b61532b83a73726dc9d3a77ecffb9c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab21a837062474bee45e04c94dc4a1610"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="pwm_8h.html#ab21a837062474bee45e04c94dc4a1610">PWM_DecreaseDutyCycle</a> ()</td></tr>
<tr class="separator:ab21a837062474bee45e04c94dc4a1610"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><dl class="section author"><dt>Author</dt><dd>K. Joseph Hass </dd></dl>
<dl class="section date"><dt>Date</dt><dd>Created: 2014-01-12T15:34:58-0500 </dd>
<dd>
Last modified: 2014-01-12T16:08:26-0500</dd></dl>
<dl class="section copyright"><dt>Copyright</dt><dd>Copyright (C) 2014 Kenneth Joseph Hass</dd>
<dd>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.</dd>
<dd>
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. </dd></dl>
</div><h2 class="groupheader">Macro Definition Documentation</h2>
<a class="anchor" id="a8ac5fa9475b8b9d3561107fa48fac8b8"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define COUNTER_TIMER_CLK&#160;&#160;&#160;(1 &lt;&lt; 8)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A mask to enable the PWM timer clock in SYSAHBCLKCTRL. </p>

</div>
</div>
<a class="anchor" id="afc17e670615df430220181dd6915ef01"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define ENABLE_TC&#160;&#160;&#160;(1 &lt;&lt; 0)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A mask to enable the PWM timer in the timer control register. </p>

</div>
</div>
<a class="anchor" id="a2914d6ed83a15536c91ec89d7e6072ec"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MATCH3_RESET&#160;&#160;&#160;(1 &lt;&lt; 10)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A mask to select Match 3 to reset the PWM_TIMER. </p>

</div>
</div>
<a class="anchor" id="aff28e7415e98ae7d3b2c88cabe778479"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MATCH_PIN&#160;&#160;&#160;PIO1_9</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Specifies the particular I/O pin that is the PWM output. </p>

</div>
</div>
<a class="anchor" id="aeb109f2e57328f6dd48e123888f364b4"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define MATCH_PIN_CONFIG&#160;&#160;&#160;(1 &lt;&lt; 0)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A mask to configure the I/O pin for the PWM output in LPC_IOCON. </p>

</div>
</div>
<a class="anchor" id="a657672b9c81af0d339260870f5b6b4fc"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PWM_DOWN_STEP&#160;&#160;&#160;9</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Factor by which duty cycle may be decreased at each system tick. </p>
<p>This factor is used to compute, at run time, an integer number of clock cycles by which the PWM low time will increase. The integer is equal to (SystemCoreClock / <a class="el" href="pwm_8h.html#a76fe84d83b8d236bd4f0d20d7e2ed06f" title="Desired PWM clock frequency, in hertz. ">PWM_FREQ</a>) &gt;&gt; <a class="el" href="pwm_8h.html#a657672b9c81af0d339260870f5b6b4fc" title="Factor by which duty cycle may be decreased at each system tick. ">PWM_DOWN_STEP</a>. If the result of this calculation is 0 then a default value of 1 is used instead.</p>
<p>Increasing the value of <a class="el" href="pwm_8h.html#a657672b9c81af0d339260870f5b6b4fc" title="Factor by which duty cycle may be decreased at each system tick. ">PWM_DOWN_STEP</a> causes the duty cycle to decrease more gradually. </p>

</div>
</div>
<a class="anchor" id="a76fe84d83b8d236bd4f0d20d7e2ed06f"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PWM_FREQ&#160;&#160;&#160;25000</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Desired PWM clock frequency, in hertz. </p>
<p>The integer number of clock cycles that is the actual PWM period is calculated at run time by dividing the system clock frequency by the desired PWM frequency, <a class="el" href="pwm_8h.html#a76fe84d83b8d236bd4f0d20d7e2ed06f" title="Desired PWM clock frequency, in hertz. ">PWM_FREQ</a>. The PWM frequency must be much less than the system clock frequency, say at least 100x lower. A higher PWM frequency may result in relatively coarser adjustments of the duty cycle. </p>

</div>
</div>
<a class="anchor" id="a7905077bb6cb0ce86fad25d4db2e884d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PWM_GPIO&#160;&#160;&#160;LPC_GPIO1</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Specifies the name of the GPIO port that includes the PWM output. </p>

</div>
</div>
<a class="anchor" id="ac28f3dd83e2453ab0fd7f97d75299c49"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PWM_MATCH0&#160;&#160;&#160;(1 &lt;&lt; 0)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A mask to select Match 0 to be the PWM_TIMER's PWM output. </p>

</div>
</div>
<a class="anchor" id="aee8f0eb1561b9783978d2094e7df220a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PWM_PIN_MSK&#160;&#160;&#160;(1 &lt;&lt; 9)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>A mask to configure a GPIO pin as an output for the PWM signal. </p>

</div>
</div>
<a class="anchor" id="aa5696c49e88a24e3144fd1433c7d20e5"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PWM_TIMER&#160;&#160;&#160;LPC_TMR16B1</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Specifies the name of the PWM timer. </p>

</div>
</div>
<a class="anchor" id="ad558a75f53ae1894cc5bfbc1b6da792b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">#define PWM_UP_STEP&#160;&#160;&#160;9</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Factor by which duty cycle may be increased at each system tick. </p>
<p>This factor is used to compute, at run time, an integer number of clock cycles by which the PWM low time will decrease. The integer is equal to (SystemCoreClock / <a class="el" href="pwm_8h.html#a76fe84d83b8d236bd4f0d20d7e2ed06f" title="Desired PWM clock frequency, in hertz. ">PWM_FREQ</a>) &gt;&gt; <a class="el" href="pwm_8h.html#ad558a75f53ae1894cc5bfbc1b6da792b" title="Factor by which duty cycle may be increased at each system tick. ">PWM_UP_STEP</a>. If the result of this calculation is 0 then a default value of 1 is used instead. </p>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a class="anchor" id="ab21a837062474bee45e04c94dc4a1610"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PWM_DecreaseDutyCycle </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Decrease the PWM duty cycle. </p>
<p>This is done by <em>increasing</em> the PWM low time in match register 0. The amount by which the low time is changed is specified indirectly by PWM_DownStep, and directly by PWM_DownValue. We check to make sure that the low time will never become equal to or greater than the PWM period. </p>

</div>
</div>
<a class="anchor" id="a70b61532b83a73726dc9d3a77ecffb9c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PWM_IncreaseDutyCycle </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Increase the PWM duty cycle. </p>
<p>This is done by <em>decreasing</em> the PWM low time in match register 0. The amount by which the low time is changed is determined indirectly by PWM_UpStep, and directly by PWM_UpValue. We check to make sure that the low time will never go to zero or negative. </p>

</div>
</div>
<a class="anchor" id="ad98784381838376693316887a2c3bf7a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PWM_Start </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Configure and initialize the PWM output. </p>
<p>Performs all of the initialization needed for the PWM output but sets the current duty cycle to zero. The particular GPIO pin that will act as the output of the timer/counter match register is configured for that function. The internal clock signal to the timer/counter is enabled. The timer/counter is configured for pulse-width modulation where match register 3 sets the period and match register 0 sets the low time.</p>
<p>The initial value of the low time is set equal to the period, which has the effect of holding the PWM output continuously low.</p>
<p>Finally, the values used to increase or decrease the PWM duty cycle are initialized as a fraction of the total period. Since the PWM period is determined at run time these are also calculated at run time, but if the desired size for the increase or decrease is too small then a default value of 1 clock cycle will be used. These two values are implemented as global variables rather than compile-time constants so we can modify the behavior for different modes of operation.</p>
<dl class="section note"><dt>Note</dt><dd>The value stored in Match Register 0 (MR0) sets the <b>low time</b> of the PWM output, which is not intuitive. Loading MR0 with the same value as the PWM period causes the PWM output to be continuously low so the resulting duty cycle is 0%. Loading MR0 with a value of 0 causes the PWM output to be continuously high, a duty cycle of 100%. </dd></dl>

</div>
</div>
<a class="anchor" id="a28a184018d9eeae0a6588e054ffe8e14"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void PWM_Stop </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Stop and disable the PWM signal. </p>
<p>First set the low time of the PWM signal to be equal to the period, so that the PWM output will always be low. Just for good measure we change the PWM output pin back to its GPIO function and write a 0 to that bit. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_bfccd401955b95cf8c75461437045ac0.html">inc</a></li><li class="navelem"><a class="el" href="pwm_8h.html">pwm.h</a></li>
    <li class="footer">Generated on Mon Jan 13 2014 08:36:57 for BatteryCharger by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6 </li>
  </ul>
</div>
</body>
</html>
